[id].vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <main class="index_main">
  10. <!-- 面包屑导航 -->
  11. <div class="breadcrumb">
  12. <div class="inner">
  13. <span class="location">当前位置:</span>
  14. <el-breadcrumb :separator-icon="ArrowRight">
  15. <el-breadcrumb-item>
  16. <NuxtLink to="/">首页</NuxtLink>
  17. </el-breadcrumb-item>
  18. <el-breadcrumb-item v-if="parent_name != ''">
  19. <NuxtLink :to="`/${targetSegment}/index.html`"> {{ parent_name }}</NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>
  22. <NuxtLink :to="`list-1.html`"> {{ routLevelTitle }}</NuxtLink>
  23. </el-breadcrumb-item>
  24. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  25. </el-breadcrumb>
  26. </div>
  27. </div>
  28. <section class="index_2 clearfix">
  29. <img class="index_2_img" :src="img_one" :title="newsDetail.title" :alt="newsDetail.title">
  30. <div class="index_2_right">
  31. <h4 class="index_2_h4">{{ newsDetail.title }}</h4>
  32. <div class="index_2_ul clearfix">
  33. <div class="index_2_li clearfix">
  34. <label class="index_2_li_label">企业名称</label>
  35. <span class="index_2_li_text">{{ newsDetail.business_name }}</span>
  36. </div>
  37. <div class="index_2_li clearfix">
  38. <label class="index_2_li_label">联 系 人</label>
  39. <span class="index_2_li_text">{{ newsDetail.content_person }}</span>
  40. </div>
  41. <div class="index_2_li clearfix">
  42. <label class="index_2_li_label">电 &nbsp;&nbsp;&nbsp;&nbsp; 话</label>
  43. <span class="index_2_li_text">{{ newsDetail.telephone }}</span>
  44. </div>
  45. <div class="index_2_li clearfix">
  46. <label class="index_2_li_label">手 &nbsp;&nbsp;&nbsp;&nbsp; 机</label>
  47. <span class="index_2_li_text">{{ newsDetail.mobile }}</span>
  48. </div>
  49. <div class="index_2_li clearfix">
  50. <label class="index_2_li_label">传 &nbsp;&nbsp;&nbsp;&nbsp; 真</label>
  51. <span class="index_2_li_text">{{ newsDetail.fax }}</span>
  52. </div>
  53. <div class="index_2_li clearfix">
  54. <label class="index_2_li_label">邮 &nbsp;&nbsp;&nbsp;&nbsp; 箱</label>
  55. <span class="index_2_li_text">{{ newsDetail.email }}</span>
  56. </div>
  57. <div class="index_2_li clearfix">
  58. <label class="index_2_li_label">邮 &nbsp;&nbsp;&nbsp;&nbsp; 编</label>
  59. <span class="index_2_li_text">{{ newsDetail.post_code }}</span>
  60. </div>
  61. <div class="index_2_li clearfix">
  62. <label class="index_2_li_label">地 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
  63. <span class="index_2_li_text">{{ newsDetail.address }}</span>
  64. </div>
  65. </div>
  66. </div>
  67. </section>
  68. <section class="index_3 clearfix">
  69. <div class="show_head_box clearfix">
  70. <span class="show_head_a show_head_a_only">项目介绍</span>
  71. </div>
  72. <article class="show_article" v-html="newsDetail.introduce">
  73. </article>
  74. </section>
  75. <section class="index_4 clearfix">
  76. <div class="show_head_box_2 clearfix">
  77. <span class="show_head_a_2 show_head_a_only_2">加盟详情</span>
  78. </div>
  79. <article class="show_article_2" v-html="newsDetail.franchise_details">
  80. </article>
  81. </section>
  82. <section class="index_4 clearfix">
  83. <div class="show_head_box_3 clearfix">
  84. <span class="show_head_a_3 show_head_a_only_3">图片展示</span>
  85. </div>
  86. <div class="img_ul_1 clearfix">
  87. <div class="img_li_1" title="" v-for="(item, index) in imgList" :key="index">
  88. <img class="img_li_1_img" :src="item" :title="newsDetail.title" :alt="newsDetail.title">
  89. </div>
  90. </div>
  91. </section>
  92. <section class="index_5 clearfix">
  93. <div class="index_2_head clearfix">
  94. <span class="index_2_head_a index_2_head_a_only" title="">精品项目推荐</span>
  95. </div>
  96. <div class="categ_ul_img_1">
  97. <div class="categ_li_img_1" v-for="(item, index) in recommend" :key="index">
  98. <a class="categ_li_img_1_a" :href="getLinkPathDetail(item)" :title="item.title">
  99. <img class="categ_li_img_1_img" :src="item.imgurl" :title="item.title" :alt="item.title">
  100. <div class="categ_li_img_1_dot2 dot2">
  101. {{ item.title }}
  102. </div>
  103. </a>
  104. </div>
  105. </div>
  106. </section>
  107. </main>
  108. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  109. <!-- 页面底部 -->
  110. <HomeFoot1></HomeFoot1>
  111. </template>
  112. <script setup>
  113. //1.页面依赖 start ---------------------------------------->
  114. import { onMounted } from 'vue'
  115. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  116. import { ArrowRight } from '@element-plus/icons-vue'
  117. //1.页面依赖 end ---------------------------------------->
  118. //2.页面路径 start ---------------------------------------->
  119. const route = useRoute();
  120. const articleId = parseInt(route.params.id);
  121. const targetSegment = getRoutePath(1);
  122. const targetSegment1 = getRoutePath(2);
  123. const parent_name = ref("");
  124. const parent_id = ref("");
  125. //通过导航路径反向查询导航id
  126. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  127. method: 'GET',
  128. query: {
  129. 'pinyin': targetSegment,
  130. },
  131. });
  132. if (getRouteId.code == 200) {
  133. parent_name.value = getRouteId.data.alias;
  134. parent_id.value = getRouteId.data.category_id;
  135. } else {
  136. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  137. console.log("错误位置:通过url路径查询导航池id")
  138. console.log("后端错误反馈:", getRouteId.message)
  139. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  140. }
  141. //2.页面路径 end ---------------------------------------->
  142. //3.面包屑 start ---------------------------------------->
  143. const routLevelTitle = ref("");
  144. const routLevelId = ref("");
  145. const getRouteId1 = await requestDataPromise('/web/getWebsiteRoute', {
  146. method: 'GET',
  147. query: {
  148. 'pinyin': targetSegment1,
  149. },
  150. });
  151. if (getRouteId1.code == 200) {
  152. routLevelTitle.value = getRouteId1.data.alias;
  153. routLevelId.value = getRouteId1.data.category_id;
  154. } else {
  155. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  156. console.log("错误位置:通过url路径查询导航池id")
  157. console.log("后端错误反馈:", getRouteId.message)
  158. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  159. }
  160. //3.面包屑 end ---------------------------------------->
  161. //4.新闻详情 start ---------------------------------------->
  162. //4.1 资讯详情
  163. const newsDetail = ref({})
  164. const routeNewsTtitle = ref("");
  165. //4.2 发布日期
  166. const time = ref("");
  167. // 图片列表
  168. const imgList = ref([]);
  169. const img_one = ref("");
  170. //4.3 获取详情
  171. let seoTitle;
  172. let seoDescription;
  173. let seoKeywords;
  174. async function getPageData() {
  175. const mkdata = await requestDataPromise('/web/getWebsiteProjectInfo', {
  176. method: 'GET',
  177. query: {
  178. 'id': articleId
  179. },
  180. });
  181. if (mkdata.code == 200) {
  182. //获取内容
  183. newsDetail.value = mkdata.data;
  184. //获取发布时间
  185. time.value = newsDetail.value.updated_at.split(' ')[0];
  186. //修正标题长度
  187. if (newsDetail.value.title.length >= 20) {
  188. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  189. } else {
  190. routeNewsTtitle.value = newsDetail.value.title
  191. }
  192. // 图片列表
  193. imgList.value = JSON.parse(mkdata.data.imgurl);
  194. img_one.value = imgList.value[0];
  195. seoTitle = newsDetail.value.title;
  196. seoDescription = newsDetail.value.description;
  197. seoKeywords = newsDetail.value.keyword;
  198. } else {
  199. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  200. console.log("错误位置:获取详情内容")
  201. console.log("后端错误反馈:", mkdata.message)
  202. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  203. }
  204. }
  205. getPageData();
  206. //4.新闻详情 end ---------------------------------------->
  207. // 推荐
  208. let getJson1 = [
  209. { "level": "1,12,0" },
  210. ]
  211. let jsonString1 = JSON.stringify(getJson1);
  212. getPageHotData(jsonString1);
  213. // 获取推荐数据
  214. let recommend = ref([]);
  215. async function getPageHotData(jsonString1) {
  216. const mkdata = await requestDataPromise('/web/getWebsiteProject', {
  217. method: 'GET',
  218. query: {
  219. 'id': jsonString1
  220. },
  221. });
  222. console.log('mkdata_HotData', mkdata.data)
  223. if (mkdata.code == 200) {
  224. if (mkdata.data.length > 0) {
  225. recommend.value = mkdata.data[0].img_num;
  226. }
  227. } else {
  228. ElMessage.error(mkdata.message)
  229. }
  230. }
  231. //5.设置seo信息 start---------------------------------------->
  232. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  233. method: 'GET',
  234. query: {
  235. 'catid': parent_id.value
  236. },
  237. });
  238. if (setData.code == 200) {
  239. let seoSuffix = setData.data.suffix;
  240. let seoName = setData.data.website_name;
  241. useSeoMeta({
  242. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  243. meta: [
  244. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  245. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  246. ]
  247. });
  248. } else {
  249. console.log("设置频道页SEO出错!", setData.message)
  250. }
  251. //5.设置seo信息 end---------------------------------------->
  252. //6.广告 start ---------------------------------------->
  253. let adImg1 = ref([]);
  254. let adImg2 = ref([]);
  255. onMounted(async () => {
  256. const { $webUrl, $CwebUrl } = useNuxtApp();
  257. //广告1
  258. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_detail_0001`
  259. const responseAd1 = await fetch(url, {
  260. headers: {
  261. 'Content-Type': 'application/json',
  262. 'Userurl': $CwebUrl,
  263. 'Origin': $CwebUrl
  264. }
  265. });
  266. const resultAd1 = await responseAd1.json();
  267. adImg1.value = resultAd1.data[0];
  268. //广告2
  269. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_detail_0002`
  270. const responseAd2 = await fetch(url2, {
  271. headers: {
  272. 'Content-Type': 'application/json',
  273. 'Userurl': $CwebUrl,
  274. 'Origin': $CwebUrl
  275. }
  276. });
  277. const resultAd2 = await responseAd2.json();
  278. adImg2.value = resultAd2.data[0];
  279. })
  280. //6.广告 end ---------------------------------------->
  281. //8.页面图片放大 start---------------------------------------->
  282. const previewVisible = ref(false)
  283. const selectedImage = ref(' ')
  284. const openPreview = (event) => {
  285. if (event.target.tagName === 'IMG') {
  286. selectedImage.value = event.target.src;
  287. previewVisible.value = true;
  288. }
  289. }
  290. const closePreview = () => {
  291. previewVisible.value = false;
  292. }
  293. //8.页面图片放大 end---------------------------------------->
  294. </script>
  295. <style lang="less" scoped>
  296. @import url('@/assets/css/project/detail.less');
  297. </style>